import 'package:flutter/material.dart';
import 'package:flutter_channel_demo/utils/tools.dart';

class MyContracts extends StatelessWidget {
  final int count;

  const MyContracts({super.key, required this.count});

  @override
  Widget build(BuildContext context) {
    return Card(
        color: Colors.white,
        margin: const EdgeInsets.all(10),
        child: Container(
            padding: const EdgeInsets.all(16),
            child: Column(
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    const Text('我的合同',
                        style: TextStyle(
                            fontSize: 16, fontWeight: FontWeight.bold)),
                    GestureDetector(
                        onTap: () => switchTab(context, '/contracts'), // 跳转到合同页
                        child: const Icon(Icons.keyboard_arrow_right))
                  ],
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 20),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Expanded(
                          flex: 1,
                          child: GestureDetector(
                            child: SizedBox(
                              height: 100,
                              child: Column(
                                children: [
                                  Stack(
                                    children: [
                                      const Padding(
                                        padding: EdgeInsets.only(
                                            top: 10.0, left: 10.0, right: 10.0),
                                        child: Icon(
                                          Icons.document_scanner,
                                          size: 50,
                                        ),
                                      ),
                                      if (count > 0)
                                        Positioned(
                                            top: 0,
                                            right: 5,
                                            child: ClipOval(
                                              child: Container(
                                                decoration: const BoxDecoration(
                                                    color: Colors.red),
                                                padding: const EdgeInsets.only(
                                                    top: 1,
                                                    left: 4,
                                                    bottom: 1,
                                                    right: 4),
                                                child: Text(
                                                  count.toString(),
                                                  style: const TextStyle(
                                                      fontSize: 12,
                                                      color: Colors.white),
                                                ),
                                              ),
                                            ))
                                    ],
                                  ),
                                  const Padding(
                                    padding: EdgeInsets.only(top: 10),
                                    child: Text('待签署'),
                                  ),
                                ],
                              ),
                            ),
                            onTap: () => switchTab(context, '/contracts',
                                arguments: {'status': 'WAITSIGN'}),
                          )),
                      Expanded(
                          flex: 1,
                          child: GestureDetector(
                            child: SizedBox(
                              height: 100,
                              child: Column(
                                children: const [
                                  Padding(
                                    padding: EdgeInsets.only(
                                        top: 10.0, left: 10.0, right: 10.0),
                                    child: Icon(
                                      Icons.file_download_done_rounded,
                                      size: 50,
                                    ),
                                  ),
                                  Padding(
                                    padding: EdgeInsets.only(top: 10),
                                    child: Text('已签署'),
                                  )
                                ],
                              ),
                            ),
                            onTap: () => switchTab(context, '/contracts',
                                arguments: {'status': 'SIGNED'}),
                          ))
                    ],
                  ),
                )
              ],
            )));
  }
}
